package org.openCage.artig;

import org.openCage.artig.stjx.Artifact;
import org.openCage.artig.stjx.Artig;
import org.openCage.artig.stjx.Deployed;
import org.openCage.artig.stjx.Module;

/**
 * Created by IntelliJ IDEA.
 * User: stephan
 * Date: Oct 12, 2010
 * Time: 10:51:39 AM
 * To change this template use File | Settings | File Templates.
 */
public class PrintInfo {
    private final Artifact artifact;

    public PrintInfo( Artig artig ) {

        if ( artig.getKind() instanceof Deployed ) {
            this.artifact = ((Deployed)artig.getKind()).getArtifact();
        } else if ( artig.getKind() instanceof Module) {
            this.artifact = ((Module)artig.getKind()).getArtifact();
        } else {
            throw new IllegalArgumentException( "incorrect artig" );
        }

    }

    public void print() {
        System.out.println("" + artifact.getName() + " " + artifact.getVersion() );
    }
}
